<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <meta name="description" content="">
    <meta name="author" content="">
    <link rel="icon" href="https://getbootstrap.com/docs/4.0/assets/img/favicons/favicon.ico">

    <title>员工列表</title>

    <link rel="canonical" href="https://getbootstrap.com/docs/4.0/examples/dashboard/">

    <!-- Bootstrap core CSS -->
    <link th:href="@{/CSS/bootstrap.min.css}" rel="stylesheet">

    <!-- Custom styles for this template -->
    <link th:href="@{/CSS/dashboard.css}" rel="stylesheet">
</head>
<body>
<div th:replace="~{commons/commons::navbar}"></div>
<main role="main" class="col-md-9 ml-sm-auto col-lg-10 pt-3 px-4">
    <div class="container-fluid">
        <div class="row">
            <div th:replace="~{commons/commons::sidebar(styles='list')}"></div>
            <h1>员工列表</h1>

            <div class="table-responsive">
                <a th:href="@{/toAdd}" class="btn btn-sm btn-success">添加员工</a>
                <table class="table table-striped table-sm">
                    <thead>
                    <tr>
                        <th>id</th>
                        <th>lastName</th>
                        <th>email</th>
                        <th>sex</th>
                        <th>department</th>
                        <th>birthday</th>
                        <th>操作</th>
                    </tr>
                    </thead>
                    <tbody>
                    <tr th:each="emp:${employees}">
                        <td th:text="${emp.getId()}"></td>
                        <td th:text="${emp.getLastName()}"></td>
                        <td th:text="${emp.getEmail()}"></td>
                        <td th:text="${emp.getSex()==0?'女':'男'}"></td>
                        <td th:text="${emp.getDepartment().getDepartmentName()}"></td>
                        <td th:text="${#dates.format(emp.getBirthday(),'yyyy-MM-dd hh:mm:ss')}"></td>
                        <td>
                            <a class="btn btn-sm btn-primary" th:href="@{/toUpdate/}+${emp.getId()}">修改</a>
                            <a class="btn btn-sm btn-danger" th:href="@{/delete/}+${emp.getId()}">删除</a>
                        </td>
                    </tr>
                    </tbody>
                </table>
            </div>
        </div>
    </div>
</main>
</body>
</html>